/**
 * 
 */   
package com.cares.infobird.service;  

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.cares.core.base.service.BaseService;
import com.cares.entity.infobird.Location;
import com.cares.infobird.repository.LocationMybatisDao;

/**   
 * @作者 Stone
 * @创建日期 2014-9-28 下午1:21:32
 * @版本 V1.0
 * @类说明
 */
@Service("locationService")
@Transactional(readOnly = true)
public class LocationService extends BaseService {
	@Autowired
	private LocationMybatisDao locationDao;
	
	/**
	 * 根据主键获取location信息
	 * @param id
	 * @return
	 */
	public Location get(Long id) {
		return locationDao.get(id);
	}
	
	/**
	 * 根据手机号码前7位查询归属地信息
	 * @param phoneNo
	 * @return
	 */
	public Location find(String phoneNo) {
		phoneNo = phoneNo.substring(0, 7);
		Location result = locationDao.find(phoneNo);
		if(result==null) {
			result = new Location();
			result.setProvince("其他");
			result.setCity("其他");
		}
		return result;
	}

}
